import service from "@/api/index.js";

const categoryApi ={
  //添加
    insert(category){
        return service.post("/category",category);
    },
    //删除
    delete(id){
        return service.delete(`/category/${id}`);
    },
    update(category){
        return service.put("/category",category);
    },
    selectByPage(condition,pageNum,pageSize) {
        if(pageNum){
            condition.pageNum = pageNum;
        }

        if(pageSize){
            condition.pageSize = pageSize;
        }
        return service.get("/category/search",{
            params:condition
        })
    },
    selectById(id){
        return service.get(`/category/${id}`,);
    },
    //查询所有父分类
    selectAllParent(){
        return service.get("/category/allParent");
    }
};
export default categoryApi;